home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac: Not for Sale / Another.not.for.sale (Australia).iso / fade into you / getting there / Apps / MOO-1.7.6.src / inc / opcode.h < prev    next >
Text File  |  1994-11-02  |  4KB  |  120 lines

  1. /******************************************************************************
  2.   Copyright (c) 1992 Xerox Corporation.  All rights reserved.
  3.   Portions of this code were written by Stephen White, aka ghond.
  4.   Use and copying of this software and preparation of derivative works based
  5.   upon this software are permitted.  Any distribution of this software or
  6.   derivative works must comply with all applicable United States export
  7.   control laws.  This software is made available AS IS, and Xerox Corporation
  8.   makes no warranty about the software, its performance or its conformity to
  9.   any specification.  Any person obtaining a copy of this software is requested
  10.   to send their name and post office or electronic mail address to:
  11.     Pavel Curtis
  12.     Xerox PARC
  13.     3333 Coyote Hill Rd.
  14.     Palo Alto, CA 94304
  15.     Pavel@Xerox.Com
  16.  *****************************************************************************/
  17.  
  18. /*#define AST_h 1*/
  19.  
  20. #ifndef Opcode_h
  21. #define Opcode_h 1
  22.  
  23. #define NUM_BUILTIN_NAMES 16
  24. #define NUM_READY_VARS 32
  25.  
  26. enum Extended_Opcode {
  27.     OP_RANGESET,
  28.     Last_Extended_Opcode = 255
  29.     };
  30.  
  31. enum Opcode {
  32.  
  33.     /* control/statement constructs with 1 tick: */
  34.     OP_IF, OP_WHILE, OP_EIF, OP_FORK, OP_FORK_WITH_ID, OP_FOR_LIST,
  35.     OP_FOR_RANGE,
  36.  
  37.     /* expr-related opcodes with 1 tick: */
  38.     OP_INDEXSET, OP_PUSH_GET_PROP, OP_GET_PROP, OP_CALL_VERB, OP_PUT_PROP,
  39.     OP_BI_FUNC_CALL, OP_IF_QUES, OP_REF, OP_RANGE_REF, 
  40.  
  41.     /* arglist-related opcodes with 1 tick: */
  42.     OP_MAKE_SINGLETON_LIST, OP_CHECK_LIST_FOR_SPLICE,
  43.  
  44.     /* arith binary ops -- 1 tick: */
  45.     OP_MULT, OP_DIV, OP_MOD, OP_ADD, OP_MINUS, 
  46.  
  47.     /* comparison binary ops -- 1 tick: */
  48.     OP_EQ, OP_NE, OP_LT, OP_LE, OP_GT, OP_GE, OP_IN,      
  49.  
  50.     /* logic binary ops -- 1 tick: */
  51.     OP_AND, OP_OR, 
  52.  
  53.     /* unary ops -- 1 tick: */
  54.     OP_UNARY_MINUS, OP_NOT, 
  55.  
  56.     /* assignments, 1 tick: */
  57.     OP_PUT,
  58.     OP_G_PUT = OP_PUT + NUM_READY_VARS,
  59.  
  60.     /* variable references, no tick: */
  61.     OP_PUSH,
  62.     OP_G_PUSH = OP_PUSH + NUM_READY_VARS,    
  63.  
  64.     /* expr-related opcodes with no tick: */
  65.     OP_IMM, OP_MAKE_EMPTY_LIST, OP_LIST_ADD_TAIL, OP_LIST_APPEND,
  66.     OP_PUSH_REF, OP_PUT_TEMP, OP_PUSH_TEMP,
  67.  
  68.     /* control/statement constructs with no ticks: */
  69.     OP_JUMP, OP_RETURN, OP_RETURN0, OP_DONE, OP_POP, 
  70.  
  71.     OP_EXTENDED, /* Used to add more opcodes */
  72.  
  73.     OPTIM_NUM_START,
  74.     /* storage optimized imm-numbers can occupy 111-255, for 145 of them */
  75.     Last_Opcode = 255
  76.     };
  77.  
  78. #define OPTIM_NUM_LOW -10
  79. #define OPTIM_NUM_HI  (Last_Opcode - OPTIM_NUM_START + OPTIM_NUM_LOW)
  80.  
  81. #define IS_PUSH_n(o)             ((o) >= (unsigned) OP_PUSH \
  82.                   && (o) < (unsigned) OP_G_PUSH)
  83. #define IS_PUT_n(o)              ((o) >= (unsigned) OP_PUT \
  84.                   && (o) < (unsigned) OP_G_PUT)
  85. #define PUSH_n_INDEX(o)          ((o) - OP_PUSH)
  86. #define PUT_n_INDEX(o)           ((o) - OP_PUT)
  87.  
  88. #define IS_OPTIM_NUM_OPCODE(o)   ((o) >= (unsigned) OPTIM_NUM_START)
  89. #define OPCODE_TO_OPTIM_NUM(o)   ((o) - OPTIM_NUM_START + OPTIM_NUM_LOW)
  90.  
  91. #define OPTIM_NUM_TO_OPCODE(i)   (OPTIM_NUM_START + (i) - OPTIM_NUM_LOW)
  92. #define IN_OPTIM_NUM_RANGE(i)    ((i) >= OPTIM_NUM_LOW && (i) <= OPTIM_NUM_HI)
  93.  
  94. /* ARITH_COMP_BIN_OP does not include AND, OR */
  95. #define IS_ARITH_COMP_BIN_OP(o)  ((o) >= (unsigned) OP_MULT \
  96.                   && (o) <= (unsigned) OP_IN)
  97.  
  98. /* whether the opcode needs one tick */
  99. #define COUNT_TICK(o)           ((o) <= OP_G_PUT)
  100.  
  101. typedef enum Opcode Opcode;
  102.  
  103. #endif
  104.  
  105. /* $Log: opcode.h,v $
  106.  * Revision 1.4  1992/10/23  23:03:47  pavel
  107.  * Added copyright notice.
  108.  *
  109.  * Revision 1.3  1992/10/17  20:48:34  pavel
  110.  * Added some (unsigned) casts to placate over-protective compilers.
  111.  * Removed unused IS_EXPR_OP macro.
  112.  *
  113.  * Revision 1.2  1992/08/28  23:19:33  pjames
  114.  * Added Extended_Opcode enumeration, and OP_RANGESET.
  115.  * Replaced LABEL with OP_EXTENDED.
  116.  *
  117.  * Revision 1.1  1992/07/20  23:23:12  pavel
  118.  * Initial RCS-controlled version.
  119.  * */
  120.